package com.dingshi.security.view;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.TextView;

import com.dingshi.security.R;

public class LoadDialog extends Dialog {
	private Context context;
	private String msg;


	private LoadDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
		init(context);
	}

	public LoadDialog(Context context, String msg) {
		super(context);
		this.msg = msg;
		init(context);
	}

	public LoadDialog(Context context) {
		super(context,0);
		init(context);
	}

	private void init(Context context) {
		this.context = context;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		Window window = getWindow();
//		window.setBackgroundDrawableResource(android.R.color.transparent);
		ViewGroup viewGroup = (ViewGroup) getLayoutInflater().inflate(R.layout.load_progressbar, null);
		TextView text = (TextView)viewGroup.findViewById(R.id.text_loading);
		if(msg!=null) {
			text.setVisibility(View.VISIBLE);
			text.setText(msg);
		}else {
			text.setVisibility(View.GONE);
		}

		ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
		setContentView(viewGroup, params);

	}

}
